const Comment = require("../model/commentModel");
class CommentService {
  async createComment(comment) {
    return await Comment.create(comment);
  }
  async findAllComments(pageNum, pageSize) {
    const offset = (pageNum - 1) * pageSize;
    const { count, rows } = await Comment.findAndCountAll({
      offset,
      limit: pageSize * 1,
    });
    return {
      pageNum,
      pageSize,
      total: count,
      list: rows,
    };
  }
  async removeComment(id){
    return await Comment.destroy({ where: { id } });
  }
}

module.exports = new CommentService();
